﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using SqlLite;
using System.IO;

namespace SqliteDemo
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            Loaded += new RoutedEventHandler(MainWindow_Loaded);
            InitializeComponent();
        }

        void MainWindow_Loaded(object sender, RoutedEventArgs e)
        {
            //string dbPath = AppDomain.CurrentDomain.BaseDirectory + @"DataAccessSample\Model.bhyf";
            //SqlLiteHelper sqlite = new SqlLiteHelper(dbPath);
            //int effectRow = sqlite.ExeSql("insert into m_element(id,pid,ECfg) values ('1','2','Content')");
            //var array = sqlite.GetArray(@"select id,pid from m_element");
            const string dbName = "backup.db";
            string currentPath = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
            string samplePath = Path.Combine(currentPath, "WebAccess", dbName);

            DownloadFileDataProvider dataProvider = new DownloadFileDataProvider();
            dataProvider.init(@"E:\Dashboard sqlite");

            DownloadFile file = new DownloadFile()
            {
                Path = "/Seagate Dashboard/Tony's Iphone/Music/1.mp3",
                LocalPath = "/Seagate Dashboard/Tony's Iphone/Music/1.mp3",
                FileName = "1.mp3",
                Bytes = "10000",
                LastModifyTime = 137777777
            };

            dataProvider.WriteData(file);

            dataProvider.ReadDatas();

            List<DownloadFile> files = new List<DownloadFile>();
            for (int i = 1; i < 200; i++)
            {
                DownloadFile file1 = new DownloadFile()
                {
                    Path = "/Seagate Dashboard/Tony's Iphone/Music/1.mp3",
                    LocalPath = "/Seagate Dashboard/Tony's Iphone/Music/1.mp3",
                    FileName = "1.mp3",
                    Bytes = "10000",
                    LastModifyTime = 137777777
                };
                files.Add(file1);
            }

            dataProvider.WriteDatas(files);

            dataProvider.ReadDatas();

        }
    }
}
